#ifndef _WORDEDIT_H_
#define _WORDEDIT_H_

#pragma once
#include "stdafx.h"
#include "msword.h"
#include "SentencesSet.h"

class CWordEdit
{
public:
	CWordEdit(void);
	~CWordEdit(void);
	HRESULT InstallCatAddin();
	HRESULT ExitWord();
	HRESULT InitApplication();
	HRESULT Init_WordTemplate( int action);
	HRESULT OpenCommand();
	int WCommand(LPCSTR cmd, LPCSTR val);
public:
	_Application m_spApplication;
	_Document m_spDocument;
	Template m_TemplateFile; 
	CString m_TemplateFileName;
	CString m_Otext, m_Ttext, m_ocopy , m_tcopy;;

private:
	Selection m_Selection;
	Range m_copyRange, m_EditRang, m_SelectRange[4];
	CString m_SelectedText;
	Bookmark m_Bookmark;Bookmarks bookmark; 
	View m_view;
	long m_cmd;
	BOOL m_bcatbook;
	Range m_ScRange[500], CatRange[4];
	int m_nScRange, m_nCurrentRange ; 
	BOOL m_ShowHiddenText;
	Styles m_pStyles;long bold, italic; float size; 
	CString catcs[6], orgcs[4], catbookmark ;
	Style m_pCatStyle[6];
	Selection m_selection;
	CString m_filename;
	CString *m_ShortCut;
	int m_iLength;long m_lDiskId;
private:
	HRESULT WordCommandIndex(int index, int param);

	int CompCommand();
	int SaveSentence();
	int SetCloseOpenGetCommand(int cmd, int param);
	int CopySourceCommand(int cmd, int param);
	int RestoreSourceCommand(LPCSTR cmd, int param);
	int CloseCommand(LPCSTR cmd, int param);
	int OpenCommand(LPCSTR cmd, int param);

	HRESULT InitRange(void);
	HRESULT Get_ParRanges();
	HRESULT fNextTextParagraph();
	HRESULT Get_CatRanges( int k );

	HRESULT Get_EditParRanges();

	HRESULT fThreeParagraphChar();
	HRESULT fThreeParagraphChar2();
	HRESULT fThreeParagraphChar3();
	HRESULT TrimSentence(Range range);
	HRESULT Get_CurrentRange();
	HRESULT OpenCloseRestoreAction( int action, int i);
	HRESULT OpenCloseRestoreAction2( int action, int i);
	LRESULT Get_RangeState( int i );
	LRESULT Open_RangeStatus( int i , int k );
	LRESULT Close_RangeStatus( int i , int k );
	LRESULT Restore_RangeStatus( int i , int k);
	VOID Add_EditBookMark();
	VOID Delete_EditBookMark();
	HRESULT Set_EditMode( Range r , CString bstr, CString btstr);
};

#endif